package objbo.xmlparser.view.interfaces;

import org.eclipse.swt.widgets.Composite;

import objbo.xmlparser.model.bean.ElementBean;
import objbo.xmlparser.view.ui.AttributeListUI;
import objbo.xmlparser.view.ui.ContentUI;
import objbo.xmlparser.view.ui.ElementListUI;
import objbo.xmlparser.view.ui.FileControlUI;
import objbo.xmlparser.view.ui.TabUI;
import objbo.xmlparser.view.ui.XMLTreeUI;

public class UIInterFace
{
	private ElementListUI elementListUI = null;
	private ContentUI contentUI = null;
	private AttributeListUI attributeListUI = null;
	private FileControlUI fileControlUI = null;
	private TabUI tabUI = null;
	private XMLTreeUI treeUI = null;
	
	private InterFaceMain interfaces = null;
	
	
	public UIInterFace(InterFaceMain interfaces)
	{
		this.interfaces = interfaces;
	}
	
	
	
	public ElementListUI makeElementListUI(Composite parent)
	{
		return elementListUI = new ElementListUI(parent,this.interfaces);
	}



	public ContentUI makeContentUI(Composite parent)
	{
		return contentUI = new ContentUI(parent,this.interfaces);
	}



	public AttributeListUI makeAttributeListUI(Composite parent)
	{
		return attributeListUI = new AttributeListUI(parent,this.interfaces);
	}



	public FileControlUI makeFileControlUI(Composite parent)
	{
		return fileControlUI = new FileControlUI(parent,this.interfaces);
	}



	public TabUI makeTabUI(Composite parent)
	{
		return tabUI = new TabUI(parent,this.interfaces);
	}



	public XMLTreeUI makeTreeUI(Composite parent)
	{
		return treeUI = new XMLTreeUI(parent,this.interfaces);
	}

	

	public void setTabElementData(ElementBean elementBean)
	{
		ElementBean reloadedElementBean = null;
		if(this.tabUI != null)
		{
			cleatTabText();
			reloadedElementBean = this.interfaces.getElementInterFace().getElement(elementBean);
			this.tabUI.setData(reloadedElementBean);
		}
	}
	
	public void cleatTabText()
	{
		if(this.tabUI != null)
		{
			this.tabUI.clear();
		}
	}
	
	
	
	
	public void setTreeUIInput()
	{
		try
		{
			if(this.treeUI != null)
			{
				this.treeUI.setInput();
			}
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
		
	}
	
	public void refreshTreeUI()
	{
		if(this.treeUI != null)
		{
			this.treeUI.refresh();
		}
	}
	


}
